//@author A0103459H

#pragma once
#ifndef interpreter_H
#define interpreter_H

#include <iostream>
#include <string>
#include <vector>
#include <time.h>
#include <regex>
#include "StatusMessages.h"
#include <assert.h>
#include <algorithm>
#include <sstream>


using namespace std;

class Interpreter {	
public :
	
	vector<string> interpret (string userInput, string *command, int* returnFlag);

	void splitWords(string userInput);
	void assignTempWordsToTaskData();
	int updateStartEndTime();

	time_t getCurrentTimeInTime_T();
	time_t interpretDateTime (string timeInput, int *returnFlag);
	string createStdTimeStringForInput(string timeInput, int* returnFlag);
	string convert12hrTo24hr (string input12hr);
	string convertStdDate (string inputDate);
	string convertStdDateFromDayName (string inputDayName);
	int updateTimeToCtimeFormat(string &timeString, time_t &timeInTime_T);
	void assignOnToFromTo();
	
	int mapDayOfWeekToInt(const string& str);
	int calculateNumberOfDaysFromToday(string inputDayName, int todayDayNameIndex);

	bool isValidDateTime (string interpretedTime, string userInputInStdStringFormat);
	bool isStartBeforeEnd(time_t startTime, time_t endTime);
	bool isCTimeFormat (string timeInput);

	void initializeTaskDataWithEmptyStrings();
	string extractFirstWordInLowerCase();
	

private:
		
	vector<string> taskData;
	vector<string> tempWords;

	static const string ZERO_STRING;

	static const regex dateTimeFormatInCtime;
	static const regex dateFormat1;
	static const regex dateFormat2;
	static const regex dateFormat3;
	static const regex dateFormat4;
	static const regex timeFormat1;
	static const regex timeFormat2;

	static const string IDENTIFIER_VENUE;
	static const string IDENTIFIER_START_TIME;
	static const string IDENTIFIER_START_END_DATE;
	static const string IDENTIFIER_END_TIME_TO;
	static const string IDENTIFIER_END_TIME_BY;
	static const string IDENTIFIER_RENAME;

	static const string STD_DATE_FORMAT;

	static const string NOW_KEYWORD;
	static const string TODAY_KEY_WORD;          
	static const string TODAY_KEY_WORD_SHORTCUT;
	static const string TOMORROW_KEY_WORD;
	static const string TOMORROW_KEY_WORD_SHORTCUT;
	static const string MON_KEY_WORD;
	static const string MON_FULL_KEY_WORD;
	static const string TUE_KEY_WORD;
	static const string TUE_FULL_KEY_WORD;
	static const string WED_KEY_WORD;
	static const string WED_FULL_KEY_WORD;
	static const string THU_KEY_WORD;
	static const string THU_FULL_KEY_WORD;
	static const string FRI_KEY_WORD;
	static const string FRI_FULL_KEY_WORD;
	static const string SAT_KEY_WORD;
	static const string SAT_FULL_KEY_WORD;
	static const string SUN_KEY_WORD;
	static const string SUN_FULL_KEY_WORD;
	static const string AM_KEYWORD;
	static const string PM_KEYWORD;
	static const string ZERO_ZERO;
	static const string EMPTY_STRING;
	static const string YEAR_FIRST_TWO_DIGITS_STRING;

	static const char SPACE;
	static const char SLASH;
	static const char DOT;
	static const char DASH;
	static const char COLON;

	static const int INT_SUNDAY                           = 0;
	static const int INT_MONDAY                           = 1;
	static const int INT_TUESDAY                          = 2;
	static const int INT_WEDNESDAY                        = 3;
	static const int INT_THURSDAY                         = 4;
	static const int INT_FRIDAY                           = 5;
	static const int INT_SATURDAY                         = 6;
	static const int ZERO_INT;
	static const int REGEX_MATCH_NUM;
	static const int MAX_NUM_OF_DIGITS_IN_DAY_MONTH;
	static const int INTERNAL_ERROR_SIGNAL;
	static const int NUM_DAYS_IN_A_WEEK;

				
	string removeAllSpacesFromString(string input);
	string addZeroFromFront(string inString);
	void removeEndWhiteSpaces(vector<string> &input);
	string toLowerString (string input);
	int wordCounter(string input);
};



#endif

